package com.zhku.orders.api;


import com.zhku.base.model.PageParams;
import com.zhku.base.model.PageResult;
import com.zhku.base.model.RestResponse;
import com.zhku.orders.model.dto.*;
import com.zhku.orders.service.TtOrdersLogisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(value = "物流表相关接口",tags = "物流表相关接口")
@RestController
public class TtOrderLogisticsController {

    @Autowired
    private TtOrdersLogisticsService ttOrdersLogisticsService;

    @ApiOperation("通用查询物流接口")
    @GetMapping("/commonLogistics/{id}")
    public RestResponse<ReturnLogisticsDto> getUserLogistics(@PathVariable("id") String id){
        ReturnLogisticsDto ttOrdersLogistics = ttOrdersLogisticsService.getUserLogistics(id);
        return RestResponse.success(ttOrdersLogistics);
    }

    @ApiOperation("分页当前用户的所有物流表")
    @PostMapping("/userLogistics/list")
    public PageResult<ReturnLogisticsDto> list(PageParams pageParams, @RequestBody(required = false) QueryUserOrder queryUserOrder){
        PageResult<ReturnLogisticsDto> ttOrdersLogisticsPageResult = ttOrdersLogisticsService.queryUserLogisticsList(pageParams, queryUserOrder);
        return ttOrdersLogisticsPageResult;
    }

    @ApiOperation("分页当前店铺的所有物流表")
    @PostMapping("/shopLogistics/list")
    public PageResult<ReturnLogisticsDto> list(PageParams pageParams, @RequestBody(required = false) QueryShopOrder queryShopOrder){
        PageResult<ReturnLogisticsDto> ttOrdersLogisticsPageResult = ttOrdersLogisticsService.queryShopLogisticsList(pageParams, queryShopOrder);
        return ttOrdersLogisticsPageResult;
    }

    @ApiOperation("商家确认发货")
    @PostMapping("/shop/confirm/{id}")
    public RestResponse shopConfirm(@PathVariable("id") String id, @RequestBody(required = false) AddressDto addressDto){
        ttOrdersLogisticsService.shopConfirm(id,addressDto);
        return RestResponse.success();
    }

    @ApiOperation("用户确认收货")
    @PostMapping("/user/confirm/{id}")
    public RestResponse userConfirm(@PathVariable("id") String id){
        ttOrdersLogisticsService.userConfirm(id);
        return RestResponse.success();
    }

    @ApiOperation("判断用户是否有对商品进行评价的资格")
    @PostMapping("/verifyEvaluate")
    public boolean verifyEvaluate(@RequestBody(required = false) VerifyEvaluateDto verifyEvaluateDto){
        boolean flag = ttOrdersLogisticsService.verifyEvaluate(verifyEvaluateDto);
        return flag;
    }

}
